package com.globallogic.oopbasics.competence.entity.creator;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import com.globallogic.oopbasics.competence.entity.SpecialistProfile;
import com.globallogic.oopbasics.competence.entity.SpecialityProfile;
import com.globallogic.oopbasics.competence.exception.LevelException;
import com.globallogic.oopbasics.competence.io.CompetencyScanner;
import com.globallogic.oopbasics.competence.io.CompetencyValueScanner;
import com.globallogic.oopbasics.competence.io.SpecialistScanner;
import com.globallogic.oopbasics.competence.io.SpecialityProfileScanner;
import com.globallogic.oopbasics.competence.io.SpecialityScanner;

/**
 * @author olena.strelchuk
 */

/**
 * Create Specialist Profile by reading and initializing from files
 */
public class SpecialistProfileCreator {

	private static final String SPECIALIST_PROFILE_DAT = "SpecialistProfile.dat"; // "EmptyForTest.dat";
	private static final String SPECIALITY_PROFILE_DAT = "SpecialityProfile.dat"; // "EmptyForTest.dat";
	private static final String SPECIALIST_DAT = "Specialist.dat";
	private static final String COMPETENCY_REF_BOOK_DAT = "CompetencyRefBook.dat";
	private static final String SPECIALITY_DAT = "Speciality.dat"; // "EmptyLinesForTest.dat";

	private static final String A_FILE_NAME = System.getProperty("user.dir")
			+ File.separator + "data" + File.separator;

	private List<SpecialityProfile> specialityProfiles = new ArrayList<SpecialityProfile>();
	private List<SpecialistProfile> specialistProfiles;

	public SpecialistProfileCreator() throws FileNotFoundException,
			LevelException {

		// Create Specialities
		SpecialityScanner specialityParser = new SpecialityScanner(A_FILE_NAME
				+ SPECIALITY_DAT);

		// Create Competencies List
		CompetencyScanner parser = new CompetencyScanner(A_FILE_NAME
				+ COMPETENCY_REF_BOOK_DAT);
		// Create Specialist
		SpecialistScanner specialistParser = new SpecialistScanner(A_FILE_NAME
				+ SPECIALIST_DAT);

		// Create Speciality Profile for Specialities
		SpecialityProfileScanner specialityProfileParser = new SpecialityProfileScanner(
				A_FILE_NAME + SPECIALITY_PROFILE_DAT,
				specialityParser.getSpecialities(),
				parser.getCompetenciesList());

		setSpecialityProfiles(specialityProfileParser.getSpecialityProfiles());

		CompetencyValueScanner competencyValueParser = new CompetencyValueScanner(
				A_FILE_NAME + SPECIALIST_PROFILE_DAT,
				specialistParser.getSpecialists(),
				specialityProfileParser.getSpecialityProfiles(),
				parser.getCompetenciesList());

		setSpecialistProfiles(competencyValueParser.getSpecialistProfiles());
	}

	public List<SpecialityProfile> getSpecialityProfiles() {
		return specialityProfiles;
	}

	public void setSpecialityProfiles(List<SpecialityProfile> specialityProfiles) {
		this.specialityProfiles = specialityProfiles;
	}

	public List<SpecialistProfile> getSpecialistProfiles() {
		return specialistProfiles;
	}

	public void setSpecialistProfiles(List<SpecialistProfile> specialistProfiles) {
		this.specialistProfiles = specialistProfiles;
	}
}
